package cn.dankal.lequ.ui.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import cn.dankal.lequ.R;
import cn.dankal.lequ.commom.adapter.BaseAdapter.ViewHolder;
import cn.dankal.lequ.commom.adapter.BaseAdapter.recyclerview.CommonAdapter;

public class MyAppActivity extends AppCompatActivity {
    @Bind(R.id.recyclerview)
    RecyclerView recyclerview;

    LinearLayoutManager linearLayoutManager;
    private boolean isClick = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_myapp);
        ButterKnife.bind(this);
        initRecyclerView();
    }

    private void initRecyclerView() {
        linearLayoutManager = new LinearLayoutManager(this);
        recyclerview.setLayoutManager(linearLayoutManager);
        recyclerview.setHasFixedSize(true);

        List<Integer> mDatas = new ArrayList<>();
        mDatas.add(1);
        mDatas.add(2);
        mDatas.add(3);
        mDatas.add(4);
        mDatas.add(5);
        mDatas.add(6);
        mDatas.add(7);
        mDatas.add(8);
        mDatas.add(9);
        mDatas.add(10);
        mDatas.add(11);
        recyclerview.setAdapter(new CommonAdapter<Integer>(this, R.layout.item_currency_myapp, mDatas) {
            @Override
            public void convert(ViewHolder holder, Integer integer) {
                holder.setOnClickListener(R.id.iv_tick, new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        ImageView iv_tick =
                                (ImageView) view.findViewById(R.id.iv_tick);
                        if (isClick == false) {

                            iv_tick.setImageResource(R.mipmap.tick_pressed);
                            isClick = true;
                        } else {
                            iv_tick.setImageResource(R.mipmap.tick);
                            isClick = false;
                        }

                    }
                });
            }


        });
    }
}
